package com.base.cn.platform.os.controller.agent.income;

import com.base.cn.platform.os.common.controller.BaseController;
import com.base.cn.platform.os.common.mybatis.Pagination;
import com.base.cn.platform.os.entity.agent.income.AgentIncome;
import com.base.cn.platform.os.service.agent.income.AgentIncomeBiz;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * 推广员总收益Controller
 *
 * @author LIZHIPENG
 * @since 2018/5/7
 */
@RestController
@RequestMapping("/course")
public class AgentIncomeController extends BaseController {

    @Autowired
    private AgentIncomeBiz agentIncomeBiz;

    /**
     * 查询收益列表（分页）
     * @param currentPage 页码
     * @param agentIncome 条件
     * @param agentUserData 是否设置推广员数据（true：是，false：否）
     * @return
     */
    @RequestMapping("/queryAgentIncomeListPage")
    public PageInfo<AgentIncome> queryAgentIncomeListPage(@RequestParam(value = "currentPage", required = false, defaultValue = "1")int currentPage,
                                                          @RequestBody AgentIncome agentIncome,
                                                          @RequestParam("agentUserData") boolean agentUserData){
        Pagination page = new Pagination();
        page.setCurrentPage(currentPage);
        return agentIncomeBiz.queryAgentIncomeListPage(page, agentIncome, agentUserData);
    }

    /**
     * 根据推广员ID查询总收益
     * @param agentUserId 推广员ID
     * @param agentUserData 是否设置推广员数据（true：是，false：否）
     * @return
     */
    @RequestMapping("/findAgentIncomeById")
    public AgentIncome findAgentIncomeById(@RequestParam("agentUserId") BigDecimal agentUserId,
                                           @RequestParam("agentUserData") boolean agentUserData){
        return agentIncomeBiz.findAgentIncomeById(agentUserId, agentUserData);
    }
}
